
************
**Figure 2**
************

use "Voter Endorsement Experiment Data.dta", clear

gen main_co = treat_violence
lab var main_co "Violence (Average Effect)"
gen coethnic_co = treat_violence
lab var coethnic_co "Violence (Coethnics Only)"
gen noncoethnic_co  = treat_violence
lab var noncoethnic_co "Violence (Non-Coethnics Only)"
gen rhetoric_co = treat_rhetoric
lab var rhetoric_co "Ethnic Rhetoric"
reg outcome1 main_co if tribe=="Kikuyu"|tribe=="Luo"|tribe=="Luhya"|tribe=="Kamba"|tribe=="Kalenjin"|tribe=="Somali"|tribe=="Kisii"|tribe=="Mijikenda"|tribe=="Meru"|tribe=="Turkana"|tribe=="Maasai"
estimates store main_effect
reg outcome1 coethnic_co if coethnic==1 & (tribe=="Kikuyu"|tribe=="Luo"|tribe=="Luhya"|tribe=="Kamba"|tribe=="Kalenjin"|tribe=="Somali"|tribe=="Kisii"|tribe=="Mijikenda"|tribe=="Meru"|tribe=="Turkana"|tribe=="Maasai")
estimates store coethnic_effect
reg outcome1 noncoethnic_co if coethnic==0 & (tribe=="Kikuyu"|tribe=="Luo"|tribe=="Luhya"|tribe=="Kamba"|tribe=="Kalenjin"|tribe=="Somali"|tribe=="Kisii"|tribe=="Mijikenda"|tribe=="Meru"|tribe=="Turkana"|tribe=="Maasai")
estimates store noncoethnic_effect
reg outcome2 rhetoric_co if candidate2tribe==tribe & treat_violenceonly==0
estimates store rhetoric_effect
coefplot main_effect coethnic_effect noncoethnic_effect rhetoric_effect, drop(_cons) xline(0) legend(off) pstyle(p1) xscale(range(-2/2)) xlabel(-2/2)
eststo clear

*********************
**Conjoint analysis**
*********************

*Conjoint analysis for results reported in the text

use "Voter Endorsement Experiment Data.dta", clear

**Create dataset for estimating AMCE**
gen respondent = _n
expand 2
gen candidate_no = 1
replace candidate_no = 2 if _n>=2016
gen cand_choice = 0
replace cand_choice = 1 if prop_stv74==1 & candidate_no == 1
replace cand_choice = 1 if prop_stv74==2 & candidate_no == 2
replace cand_choice = 0.5 if prop_stv74==3

gen coethnic_conjoint = 0
replace coethnic_conjoint = 1 if tribeselection1==tribe & candidate_no == 1
replace coethnic_conjoint = 1 if tribeselection2==tribe & candidate_no == 2

gen public_goods_info = 0
replace public_goods_info = 1 if candidate_no == 1 & recordcand1!=3
replace public_goods_info = 1 if candidate_no == 2 & recordcand2!=3
gen public_goods_positive = 0
replace public_goods_positive = 1 if candidate_no == 1 & recordcand1==1
replace public_goods_positive = 1 if candidate_no == 2 & recordcand2==1
gen public_goods_negative = 0
replace public_goods_negative = 1 if candidate_no == 1 & recordcand1==2
replace public_goods_negative = 1 if candidate_no == 2 & recordcand2==2
gen public_goods_record = .
replace public_goods_record = recordcand1 if candidate_no == 1
replace public_goods_record = recordcand2 if candidate_no == 2


gen violence = .
replace violence = 1 if candidate_no == 1 & electcand1==1
replace violence = 1 if candidate_no == 2 & electcand2==1
replace violence = 0 if candidate_no == 1 & electcand1==2
replace violence = 0 if candidate_no == 2 & electcand1==2

lab var violence "Violence"
lab var coethnic_conjoint "Coethnic"
lab var public_goods_positive "Positive Public Goods Record"

**Estimate AMCE of violence when candidate is coethnic w/ positive public goods record**

reg cand_choice i.violence##i.coethnic_conjoint##i.public_goods_positive
margins if coethnic_conjoint==1 & public_goods_positive==1, dydx(violence)


****************************
**Online Appendix Table A2**
****************************

use "Voter Endorsement Experiment Data.dta", clear

reg treat_violence urban female age education income violence_affected if tribe=="Kikuyu"|tribe=="Luo"|tribe=="Luhya"|tribe=="Kamba"|tribe=="Kalenjin"|tribe=="Somali"|tribe=="Kisii"|tribe=="Mijikenda"|tribe=="Meru"|tribe=="Turkana"|tribe=="Maasai"
eststo
reg treat_rhetoric urban female age education income violence_affected if candidate2tribe==tribe & treat_violenceonly==0 & treat_rhetoric_violence==0
eststo
esttab, se label star(* 0.10 ** 0.05 *** 0.01) replace
eststo clear

*************
**Figure B3**
*************

use "Voter Endorsement Experiment Data.dta", clear

gen violence_affected_co = treat_violence
lab var violence_affected_co "Violence (Violence-Affected)"
gen violence_unaffected_co = treat_violence
lab var violence_unaffected_co "Violence (Unaffected)"
gen rhetoric_affected_co = treat_rhetoric
lab var rhetoric_affected_co "Ethnic Rhetoric (Violence-Affected)"
gen rhetoric_unaffected_co = treat_rhetoric
lab var rhetoric_unaffected_co "Ethnic Rhetoric (Unaffected)"
reg outcome1 violence_affected_co if coethnic==1 & violence_affected==1 & (tribe=="Kikuyu"|tribe=="Luo"|tribe=="Luhya"|tribe=="Kamba"|tribe=="Kalenjin"|tribe=="Somali"|tribe=="Kisii"|tribe=="Mijikenda"|tribe=="Meru"|tribe=="Turkana"|tribe=="Maasai")
estimates store violence_affected_effect
reg outcome1 violence_unaffected_co if coethnic==1 & violence_affected==0 & (tribe=="Kikuyu"|tribe=="Luo"|tribe=="Luhya"|tribe=="Kamba"|tribe=="Kalenjin"|tribe=="Somali"|tribe=="Kisii"|tribe=="Mijikenda"|tribe=="Meru"|tribe=="Turkana"|tribe=="Maasai")
estimates store violence_unaffected_effect
reg outcome2 rhetoric_affected_co if violence_affected==1 & candidate2tribe==tribe & treat_violenceonly==0
estimates store rhetoric_affected_effect
reg outcome2 rhetoric_unaffected_co if violence_affected==0 & candidate2tribe==tribe & treat_violenceonly==0
estimates store rhetoric_unaffected_effect
coefplot violence_affected_effect violence_unaffected_effect rhetoric_affected_effect rhetoric_unaffected_effect, drop(_cons) xline(0) legend(off) pstyle(p1) xscale(range(-2/2)) xlabel(-2/2)
eststo clear

